﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PSDClientListener
{
    public class VersionManager
    {
        public string LocalVersion { get; set; }
        public string RemoteVersion { get; set; }

        public void Init()
        {
            LocalVersion = GetLocalVersion();
        }

        public string GetLocalVersion()
        {
            string version = "";

            return version;
        }

        public string GetRemoteVersion()
        {
            string version = "";

            return version;
        }

        public bool CheckUpdate()
        {
            bool hasNewVersion = false;

            LocalVersion = GetLocalVersion();
            RemoteVersion = GetRemoteVersion();

            string[] local = LocalVersion.Split(".".ToCharArray());
            string[] remote = RemoteVersion.Split(".".ToCharArray());

            for (int i = 0; i < local.Length; i++)
            {
                if (Convert.ToInt32(local[i]) < Convert.ToInt32(remote[i]))
                {
                    hasNewVersion = true;
                    break;
                }
            }

            return hasNewVersion;
        }

        public void UpdateFiles()
        { }
    }
}
